import { axios } from '../../utils/request'

/**
 * 出入库单据
 */
const api = {
    save: '/inOut/recordMain/save',
    examine: '/inOut/recordMain/examine',
    delete: '/inOut/recordMain/delete',
    getcode: '/inOut/recordMain/getCode',  

    purchaseSave: '/inOut/recordMain/saveOrderForWarehouse',//采购入库单 保存
    purchaseDelete: '/inOut/recordMain/deleteFromCreate',//采购入库单 删除
    confirm: '/inOut/recordMain/confirm',  //单据确认（收货）
    saveOrderForInventory: "/production/work/saveOrderForInventory", //分单 保存
    saveOrderForCustomer: "/production/order/saveOrderForCustomer", //生产计划 生成 生产订单 按客户分单


    downloadUrl: "/inOut/recordMain/downloadImportTemplate",//下载导入模板
    importUrl: "/inOut/recordMain/importData",//导入
    exportUrl: "/inOut/recordMain/exportData",

    getNowQuantity: '/in/inventoryInfo/getExistQuantityByWarehouseId',//根据 物料ID 和 仓库ID 获取现存量
    submitUrl: '/inOut/recordMain/submit',//单据提交

    boardHandVo: '/inOut/recordMain/statisticInventoryStorageOnHandVo'//看板统计 现存量
}
/**
 * 保存
 */
export function save (data) {
    return axios({
        url: api.save,
        method: "post",
        data: data
    })
}

/**
 * 审核
 */
export function examine (data) {
    return axios({
        url: api.examine,
        method: "get",
        params: data
    })
}

/**
 * 删除
 */
export function remove (data) {
    return axios({
        url: api.delete,
        method: "DELETE",
        params: data
    })
}

/**
 * 获取单据编号
 */
export function getCode (data) {
    return axios({
        url: api.getcode,
        method: "get",
        params: data
    })
}

/**
 * 采购入库保存
 */
export function purchaseSave (data) {
    return axios({
        url: api.purchaseSave,
        method: "post",
        data: data
    })
}
/**
 * 采购入库删除
 */
export function purchaseDelete (data) {
    return axios({
        url: api.purchaseDelete,
        method: "DELETE",
        params: data
    })
}

/**
 * 收货
 */

// let obj = {
//     isCheckInventoryInfo:true,
// }
export function confirm (data) {
    return axios({
        url: api.confirm,
        method: "get",
        params: data
        // params:Object.assign(obj,data)
    })
}

/**
 * 分单保存
 */
export function saveOrderForInventory (data) {
    return axios({
        url: api.saveOrderForInventory,
        method: "post",
        data: data
    })
}

/**
 * 生产计划 生成 生产订单 分单
 */
export function saveOrderForCustomer (data) {
    return axios({
        url: api.saveOrderForCustomer,
        method: "post",
        data: data
    })
}

/**
* 下载导入数据模板
*/
export function downloadDemo (parameter) {
    return axios({
        url: api.downloadUrl,
        method: "get",
        params: parameter,
        responseType: 'blob'
    });
}

/**
* 导出数据
*/
export function exportInOutData (parameter) {
    return axios({
        url: api.exportUrl,
        method: "get",
        params: parameter,
        responseType: 'blob'
    });
}

/**
 * 导入数据
 */
export function importInOutData (data) {
    return axios({
        url: api.importUrl,
        method: "post",
        data: data,
        headers: {
            "Content-Type": "multipart/form-data"
        },
        timeout: 5000000,
    });
}

/**
 * 根据 物料ID 和 仓库ID 获取现存量
 */
export function getNowQuantity (data) {
    return axios({
        url: api.getNowQuantity,
        method: "post",
        data: data,
        timeout: 5000000,
    });
}

//单据提交
export function submitOrder (data) {
    return axios({
        url: api.submitUrl,
        method: "get",
        params: data
    })
}

//看板统计 现存量
export function boardApi (data) {
    return axios({
        url: api.boardHandVo,
        method: "get",
        params: data
    })
}




